package com.hdu.xxl_job_client.res.jobGroup;

import lombok.Data;

import java.util.List;

import static java.util.Objects.nonNull;


@Data
public class XxlJobGroupExecuteRes {

    private static final Integer SUCCESS_CODE = 200;
    private static final Integer FAIL_CODE = 500;

    private Integer code;
    private String msg;
    private String content;
    private Integer recordsFiltered;
    private Integer recordsTotal;
    private List<XxlJobGroupInfoRes> data;

    public boolean isSuccess() {
        return SUCCESS_CODE.equals(code) || (nonNull(recordsTotal) && recordsTotal > 0);
    }

    public static XxlJobGroupExecuteRes fail(String msg) {
        XxlJobGroupExecuteRes xxlJobGroupExecuteRes = new XxlJobGroupExecuteRes();
        xxlJobGroupExecuteRes.setCode(FAIL_CODE);
        xxlJobGroupExecuteRes.setMsg(msg);
        return xxlJobGroupExecuteRes;
    }

}
